{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 多项式回归拟合数据练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x1aa36b4fad0>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAGdCAYAAACyzRGfAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjEsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvc2/+5QAAAAlwSFlzAAAPYQAAD2EBqD+naQAAId1JREFUeJzt3X+QVeV9P/DPLj9tgEW2wC4FFM0PQEImEJVV084oFq1jY0CbZLDVSNspJUbANJF0jKFtgm2msfoHpLEOdgaJI51gxFatQUNqgr+wplIqYqRCwy5kalnQdIGB+53ndHa/LIFEYPfZ3XNfr5nj7n2ew91zPLvnvu/z69ZUKpVKAABkUpvrBwEAJMIHAJCV8AEAZCV8AABZCR8AQFbCBwCQlfABAGQlfAAAWfWPXubIkSOxa9euGDp0aNTU1PT04QAA70Jas3T//v0xZsyYqK2t7VvhIwWPcePG9fRhAACnYOfOnTF27Ni+FT5Si0f7wQ8bNqynDwcAeBf27dtXNB60v473qfDR3tWSgofwAQB9y7sZMmHAKQCQlfABAGQlfAAAWQkfAEBWwgcAkJXwAQBkJXwAAFkJHwBAVr1ukTEAoHscPlKJ57e/FXv2t8WooYPjggkjol9t/s9REz4AoAo8vrk5lq7bEs2tbR1ljXWD446rJ8cVUxqzHotuFwCoguAxf9VLnYJH0tLaVpSn+pyEDwAoeVfL0nVbonKcuvayVJ/2y0X4AIASe377Wz/X4nG0FDlSfdovF+EDAEpsz/62Lt2vKwgfAFBio4YO7tL9uoLwAQAldsGEEcWslhNNqE3lqT7tl4vwAQAl1q+2pphOmxwbQNofp/qc630IHwBQc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pPu0HUCbCB/SQtI5Hmk6bHBtA2h+neut9AGUjfEAPSut4rLh+WjTUde5aSY9TuXU+gDKyyBj0sBQwLp/cYIVToGoIH9ALpKDRdG59Tx8GQBa6XQCAvhM+7rzzzqipqYmFCxd2lLW1tcWCBQuivr4+hgwZEnPmzIndu3d3xbECANUcPl544YX427/925g6dWqn8kWLFsW6detizZo1sWHDhti1a1fMnj27K44VAKjW8PH222/H3Llz4957740zzzyzo7y1tTXuu++++PrXvx6XXnppTJ8+PVauXBk//OEP49lnn+3K4wYAqil8pG6Vq666KmbOnNmpfNOmTXHo0KFO5RMnTozx48fHxo0bj/tcBw4ciH379nXaAIDyOunZLg8++GC89NJLRbfLsVpaWmLgwIExfPjwTuWjR48u6o5n2bJlsXTp0pM9DACgGlo+du7cGbfccks88MADMXhw13zexJIlS4rumvYt/QwAoLxOKnykbpU9e/bEtGnTon///sWWBpXec889xfephePgwYOxd+/eTv8uzXZpaGg47nMOGjQohg0b1mkDAMrrpLpdLrvssnjllVc6lX36058uxnV84QtfiHHjxsWAAQNi/fr1xRTbZOvWrbFjx45oamrq2iMHAMofPoYOHRpTpkzpVPae97ynWNOjvXzevHmxePHiGDFiRNGKcfPNNxfBY8aMGV175ABAn9Tly6vfddddUVtbW7R8pJkss2bNiuXLl3f1jwEA+qiaSqVSiV4kTbWtq6srBp8a/wEAfcPJvH77bBcAICvhAwDISvgAALISPgCArIQPACAr4QMAyEr4AACyEj4AgKyEDwAgK+EDAMhK+AAAshI+AICshA8AICvhAwDISvgAALISPgCArIQPACAr4QMAyEr4AACyEj4AgKyEDwAgK+EDAMhK+AAAshI+AICshA8AICvhAwDISvgAALISPgCArIQPACAr4QMAyEr4AACy6p/3x5XX4SOVeH77W7Fnf1uMGjo4LpgwIvrV1vT0YQEcl3sWPUn46AKPb26Opeu2RHNrW0dZY93guOPqyXHFlMYePTaAY7ln0dN0u3TBH/H8VS91+iNOWlrbivJUD9BbuGfRGwgfp9lsmd49VI5T116W6tN+AD3NPYveQ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WjRouK+lfP6Ch89LE13Shc09cG1S01izz33XNGM39ekMbUpeKRuh6eeeqo4v6OlF+cBAwZ0Ot80FTfd2Pri+f6id48HDhwo3fledtllRRdTerfUvqV3yanJtv37Mp3v8bz99tvx4x//uHiRLtv1TVI36bHT49P4gNTaU8Z7VruVK1cWY1zSWKZ2Zby+P/vZz6K2tvNLf+p+SfesrNe3y4au8gtnBvzrv/5rsaX/5V//+teL7998882OaU3Dhw+vfOc736n827/9W+VjH/tYn522Nn/+/GKK1ve+971O09d+9rOfdeyTpq6l6bdPPfVUMXWtqamp2Pqq2267rZjNk6atpeuXHtfU1FT++Z//uZTne6yjZ7uU8XxvvfXW4vc5Xd8f/OAHlZkzZ1Z+9Vd/tZjJVcbzTVOo+/fvX0zJ3LZtW+WBBx6o/Mqv/Epl1apVHfuU6Z6VHD58uLiGaabPscp2fW+44YbKr/3ar3VMtU1LQKTf589//vNZr6/wkUGaL55Cx7Fb+iVon9p0++23V0aPHl1MZ7rsssuK9SL6ouOdZ9rS2h/t0i/wH//xHxfTUdNN7eMf/3gRUPqqNG0trYswcODAysiRI4vr1x48yni+vyx8lO18P/GJT1QaGxuL65tu2unx0WtelO18k3Xr1lWmTJlS3I8mTpxY+eY3v9mpvkz3rCStY5LuU8c7h7Jd33379hV/rylQDR48uHLOOecU61AdOHAg6/WtSf/punYUAIBfzJgPACAr4QMAyEr4AACyEj4AgKyEDwAgK+EDAMhK+AAAshI+AICshA8AICvhAwDISvgAALISPgCAyOn/ARLeeCecwLY+AAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 加载示例数据\n",
    "x = [4, 8, 12, 25, 32, 43, 58, 63, 69, 79]\n",
    "y = [20, 33, 50, 56, 42, 31, 33, 46, 65, 75]\n",
    "\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "%matplotlib inline\n",
    "\n",
    "plt.scatter(x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "def func(p, x):\n",
    "    # 根据公式，定义 2 次多项式函数\n",
    "    w0, w1, w2 = p\n",
    "    f = w0 + w1 * x + w2 * x * x\n",
    "    return f\n",
    "\n",
    "\n",
    "def err_func(p, x, y):\n",
    "    # 残差函数（观测值与拟合值之间的差距）\n",
    "    ret = func(p, x) - y\n",
    "    return ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fitting Parameters:  [ 3.76893096e+01 -2.60473980e-01  8.00077882e-03]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from scipy.optimize import leastsq\n",
    "\n",
    "p_init = np.random.randn(3)  # 生成 3 个随机数\n",
    "# 使用 Scipy 提供的最小二乘法函数得到最佳拟合参数\n",
    "parameters = leastsq(err_func, p_init, args=(np.array(x), np.array(y)))\n",
    "\n",
    "print(\"Fitting Parameters: \", parameters[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x1aa36b26590>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAGdCAYAAACyzRGfAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjEsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvc2/+5QAAAAlwSFlzAAAPYQAAD2EBqD+naQAANcBJREFUeJzt3Ql4FPX9x/FPwhUlECQCCQJyeHCJFZBD8QYBKWo5FAsKiv4tInJoVTxA1BaqVUQr1KtgRaRiixoQEEFBLYeAqIgiShQqCViRBMEkmOz/+c64IYnBQkhmdmffr+eZbuYQftMNs5/9nXGhUCgkAAAAj8R79RcBA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lmn79u3q06dPRZUdQAxgHRIgeI54evXatWvrwQcfVL9+/VSnTh3NmjXL+dl8+umnatGihVasWKFOnTod0p/H9OoASsM8H0Bk82R69fz8fKeGY+/evU7zi9WG7N+/X127di28pnnz5mrUqNEvho/c3FxnK1p4ACjJAka3linMcAoEwGGHj48++sgJG9a/w/p1zJ07Vy1bttT69etVtWpV1apVq9j19erVU2Zm5kH/vIkTJ2rChAllKz2AmMI6JECMjnY5+eSTnaCxatUqDRs2TIMHD9bGjRvLXICxY8c6VTThbdu2bWX+swAAQABrPqx244QTTnB+bteund577z1NmTJFl19+ufLy8rR79+5itR822iUlJeWgf161atWcDQAAxIYjnuejoKDA6bNhQaRKlSpasmRJ4blNmzZp69atTjMNAADAYdd8WBNJz549nU6ke/bscUa2vPXWW1q0aJHTw3Xo0KEaM2aMMwLGerqOGDHCCR6HOtIFAAAE32GFj507d+qqq65SRkaGEzZswjELHt26dXPOT548WfHx8c7kYlYb0r17d02dOrWiyg4AAGJxno/yxjwfAABEn8P5/GZtFwAA4CnCBwAA8BThAwAAeIrwAQAAPEX4AAAAniJ8AAAATxE+AACApwgfAADAU4QPAADgKcIHAADwFOEDAAB4ivABAAA8RfgAAACeInwAAABPET4AAICnCB8AAMBThA8AAOApwgcAAPAU4QMAAHiK8AEAADxF+AAAAJ4ifAAAAE8RPgAAgKcIHwAAwFOEDwAA4CnCBwAA8BThAwAAeIrwAQAAPEX4AAAAniJ8AAAATxE+AACApwgfAADAU4QPAADgKcIHAADwFOEDAAB4ivABAAA8RfgAAACeInwAAABPET4AAICnCB8AAMBThA8AAOApwgcAAPAU4QMAAHiK8AEAADxF+AAAAJ4ifAAAAE8RPgAAgKcIHwAAwFOEDwAA4KnK3v51wZNfENLq9F3auSdHdWskqEOT2qoUH+d3sQAACEbNx8SJE3X66aerRo0aqlu3ri699FJt2rSp2DU5OTkaPny4kpOTlZiYqL59+2rHjh0KooUbMtTlT0t1xVMrNXL2eufV9u04AAAoh/CxbNkyJ1isXLlSixc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G3S5cudYbBde7c2dmiwe233+6M3LHhb/b+2H5cXFzo9ddfj/p7O5iio12CcI8333yz8/tp7+G7774b6tq1a+jYY491RmYF4f5siHTlypWd4ZqbN28OPf/886Gjjz46NHPmzMJrov05Ex75aO+Tje4pKdrfw8GDB4eOO+64wqG2NjWD/Y7eeuutEfEexkT4MI899pjzi2TzfdjQ25UrV4ailY1Dt9BRcrNftvAQqrvvvjtUr149J3RdcMEFznwS0aK0e7PN5v4Is38cN9xwgzNE1R6Kv/nNb5yAEg1s+JvNoWC/i3Xq1HHen3DwiPZ7O9TwEe33ePnll4dSU1Od99Ae8LZfdA6MaL8/k5aWFmrdurXzDGnevHnoySefLHY+2p8zxuYusWdLaeWO9vcwOzvb+Tdnn3sJCQmhpk2bOvND5ebmRsR7GGf/U/H1KwAAADHS5wMAAEQWwgcAAPAU4QMAAHiK8AEAADxF+AAAAJ4ifAAAAE8RPgAAgKcIHwAAwFOEDwAA4CnCBwAA8BThAwAAeIrwAQAA5KX/B2AGGyIv0k+sAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制拟合图像时需要的临时点\n",
    "x_temp = np.linspace(0, 80, 10000)\n",
    "\n",
    "# 绘制拟合函数曲线\n",
    "plt.plot(x_temp, func(parameters[0], x_temp), \"r\")\n",
    "\n",
    "# 绘制原数据点\n",
    "plt.scatter(x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "def fit_func(p, x):\n",
    "    \"\"\"根据公式，定义 n 次多项式函数\"\"\"\n",
    "    f = np.poly1d(p)\n",
    "    return f(x)\n",
    "\n",
    "\n",
    "def err_func(p, x, y):\n",
    "    \"\"\"残差函数（观测值与拟合值之间的差距）\"\"\"\n",
    "    ret = fit_func(p, x) - y\n",
    "    return ret\n",
    "\n",
    "\n",
    "def n_poly(n):\n",
    "    \"\"\"n 次多项式拟合\"\"\"\n",
    "    p_init = np.random.randn(n)  # 生成 n 个随机数\n",
    "    parameters = leastsq(err_func, p_init, args=(np.array(x), np.array(y)))\n",
    "    return parameters[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 8.00077870e-03, -2.60473971e-01,  3.76893095e+01])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n_poly(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 2.,  4.],\n",
       "       [-1.,  1.],\n",
       "       [ 3.,  9.]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.preprocessing import PolynomialFeatures\n",
    "\n",
    "X = [2, -1, 3]\n",
    "X_reshape = np.array(X).reshape(len(X), 1)  # 转换为列向量\n",
    "# 使用 PolynomialFeatures 自动生成特征矩阵\n",
    "PolynomialFeatures(degree=2, include_bias=False).fit_transform(X_reshape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[4.000e+00, 1.600e+01],\n",
       "       [8.000e+00, 6.400e+01],\n",
       "       [1.200e+01, 1.440e+02],\n",
       "       [2.500e+01, 6.250e+02],\n",
       "       [3.200e+01, 1.024e+03],\n",
       "       [4.300e+01, 1.849e+03],\n",
       "       [5.800e+01, 3.364e+03],\n",
       "       [6.300e+01, 3.969e+03],\n",
       "       [6.900e+01, 4.761e+03],\n",
       "       [7.900e+01, 6.241e+03]])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = np.array(x).reshape(len(x), 1)  # 转换为列向量\n",
    "y = np.array(y).reshape(len(y), 1)\n",
    "\n",
    "# 使用 sklearn 得到 2 次多项式回归特征矩阵\n",
    "poly_features = PolynomialFeatures(degree=2, include_bias=False)\n",
    "poly_x = poly_features.fit_transform(x)\n",
    "\n",
    "poly_x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([37.68931083]), array([[-0.26047408,  0.00800078]]))"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 定义线性回归模型\n",
    "model = LinearRegression()\n",
    "model.fit(poly_x, y)  # 训练\n",
    "\n",
    "# 得到模型拟合参数\n",
    "model.intercept_, model.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x1aa20be4590>"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAGdCAYAAACyzRGfAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjEsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvc2/+5QAAAAlwSFlzAAAPYQAAD2EBqD+naQAANcBJREFUeJzt3Ql4FPX9x/FPwhUlECQCCQJyeHCJFZBD8QYBKWo5FAsKiv4tInJoVTxA1BaqVUQr1KtgRaRiixoQEEFBLYeAqIgiShQqCViRBMEkmOz/+c64IYnBQkhmdmffr+eZbuYQftMNs5/9nXGhUCgkAAAAj8R79RcBAAAYwgcAAPAU4QMAAHiK8AEAADxF+AAAAJ4ifAAAAE8RPgAAgKcIHwAAwFOVFWEKCgq0fft21ahRQ3FxcX4XBwAAHAKbs3TPnj2qX7++4uPjoyt8WPBo2LCh38UAAABlsG3bNjVo0CC6wofVeIQLX7NmTb+LAwAADkF2drZTeRD+HI+q8BFuarH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tg8HtMGtVVKUvGmFdu34xExz0dennTZZdKCBdJRR0nz50udOytImGQMABBTLGB0a5kSmTOc/vij9NvfSq++KlWr5r6ec46ChvABAIg5FjQ6N4uwoar5+dJVVx2YsdRWq7V5PQKIZhcAAPxWUCANHSq98IK7RsucOVLPngoqwgcAAH4Hj9/9Tnr2WalSJWn2bOniixVkhA8AAPwSCkk33SQ99ZQUHy8995zUt6+CjvABAIBfwePmm6XHH5fi4qS//U264grFAsIHAAB+BI+xY6XJk939J5+UBg9WrCB8AADgtXvukf70J/dnq/m49lrFEsIHAABe1niMHy/de6+7bzUfN9ygWMM8HwAAeBk87rvP3X/wQWnUKMUiwgcAAF4Ej3HjpPvvd/cfekgaM0axivABAEBFB4+77pL++Ed3/+GHpdGjFcsIHwAAVGTwuPNOaeLEA308RsVmU0tRhA8AACoqeNxxhzRpkrv/yCPSyJF+lyoiED4AAKioeTzCw2mnTHFnMoWD8AEAQHkHj9tvlx54wN1/9FFpxAi/SxVRCB8AAJRn8Lj1VunPf3b3//IXafhwv0sVcQgfAACUV/D4/e/dYbThmUtjcAKxQ0H4AADgSBUUuH06LHCYqVOlYcP8LlXEInwAAHAk8vOl66+XnnnGXZ32iSek667zu1QRjfABAEBZ/fijNGSI9PzzUny8NGOGdOWVfpcqeAvLff311xo0aJCSk5N11FFH6ZRTTtGaNWsKz4dCIY0bN06pqanO+a5du2rz5s3lXW4AAPyVlycNGOAGj8qVpdmzCR4VET6+++47nXnmmapSpYoWLFigjRs36qGHHtIxxxxTeM0DDzygRx99VH/961+1atUqVa9eXd27d1dOTs7h/FUAAEQu+0zr21f65z+lqlXd1/79/S5V1IgLWVXFIbr99tv17rvv6u233y71vP1R9evX180336xbbrnFOZaVlaV69eppxowZGmAJ8X/Izs5WUlKS89/VrFnzcO4FAICKt2+fdOml0uLFUkKC9PLLUvfuinXZh/H5fVg1H6+++qrat2+v/v37q27dujrttNP01FNPFZ5PT09XZmam09QSZgXp2LGjVqxYUeqfmZub6xS46AYAQETas0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vy1bttT69etVtWpV1apVq9j19erVU2Zm5kH/vIkTJ2rChAllKz2AmMI6JECMjnY5+eSTnaCxatUqDRs2TIMHD9bGjRvLXICxY8c6VTThbdu2bWX+swAAQABrPqx244QTTnB+bteund577z1NmTJFl19+ufLy8rR79+5itR822iUlJeWgf161atWcDQAAxIYjnuejoKDA6bNhQaRKlSpasmRJ4blNmzZp69atTjMNAADAYdd8WBNJz549nU6ke/bscUa2vPXWW1q0aJHTw3Xo0KEaM2aMMwLGerqOGDHCCR6HOtIFAAAE32GFj507d+qqq65SRkaGEzZswjELHt26dXPOT548WfHx8c7kYlYb0r17d02dOrWiyg4AAGJxno/yxjwfAABEn8P5/GZtFwAA4CnCBwAA8BThAwAAeIrwAQAAPEX4AAAAniJ8AAAATxE+AACApwgfAADAU4QPAADgKcIHAADwFOEDAAB4ivABAAA8RfgAAACeInwAAABPET4AAICnCB8AAMBThA8AAOApwgcAAPAU4QMAAHiK8AEAADxF+AAAAJ4ifAAAAE8RPgAAgKcIHwAAwFOEDwAA4CnCBwAA8BThAwAAeIrwAQAAPEX4AAAAniJ8AAAATxE+AACApwgfAADAU4QPAADgKcIHAADwFOEDAAB4ivABAAA8RfgAAACeInwAAABPET4AAICnCB8AAMBThA8AAOApwgcAAPAU4QMAAHiK8AEAADxF+AAAAJ4ifAAAAE8RPgAAgKcIHwAAwFOEDwAA4KnK3v51wZNfENLq9F3auSdHdWskqEOT2qoUH+d3sQAACEbNx8SJE3X66aerRo0aqlu3ri699FJt2rSp2DU5OTkaPny4kpOTlZiYqL59+2rHjh0KooUbMtTlT0t1xVMrNXL2eufV9u04AAAoh/CxbNkyJ1isXLlSixcv1v79+3XhhRdq7969hdeMHj1aaWlpmjNnjnP99u3b1adPHwWNBYxhM9cpIyun2PHMrBznOAEEAIDSxYVCoZDK6JtvvnFqQCxknH322crKylKdOnU0a9Ys9evXz7nm008/VYsWLbRixQp16tTpf/6Z2dnZSkpKcv6smjVrKlKbWqyGo2TwCLNGl5SkBL1z2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jzi2TzfdjQ25UrV4ailY1Dt9BRcrNftvAQqrvvvjtUr149J3RdcMEFznwS0aK0e7PN5v4Is38cN9xwgzNE1R6Kv/nNb5yAEg1s+JvNoWC/i3Xq1HHen3DwiPZ7O9TwEe33ePnll4dSU1Od99Ae8LZfdA6MaL8/k5aWFmrdurXzDGnevHnoySefLHY+2p8zxuYusWdLaeWO9vcwOzvb+Tdnn3sJCQmhpk2bOvND5ebmRsR7GGf/U/H1KwAAADHS5wMAAEQWwgcAAPAU4QMAAHiK8AEAADxF+AAAAJ4ifAAAAE8RPgAAgKcIHwAAwFOEDwAA4CnCBwAA8BThAwAAeIrwAQAA5KX/B2AGGyIv0k+sAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制拟合图像\n",
    "x_temp = np.array(x_temp).reshape(len(x_temp), 1)\n",
    "poly_x_temp = poly_features.fit_transform(x_temp)\n",
    "\n",
    "plt.plot(x_temp, model.predict(poly_x_temp), \"r\")\n",
    "plt.scatter(x, y)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
